//
//  CoinCell.swift
//  Wallet
//
//  Created by Julian on 2022/5/7.
//

import UIKit

class CoinCell: UITableViewCell {
    
    static let reuseIndentifier = "WalletCoinID"
    
    @IBOutlet weak var iconImageView: UIImageView!
    @IBOutlet weak var nameLabel: UILabel!
    @IBOutlet weak var amountLabel: UILabel!
    @IBOutlet weak var currencyAmountLabel: UILabel!
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    
    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)
        
        // Configure the view for the selected state
    }
}

// MARK: - 界面数据绑定
extension CoinCell {
    
    func bind(vm: CoinViewModel) {
        self.iconImageView.image = UIImage(named: vm.symbol)
        self.nameLabel.text = vm.name
        self.amountLabel.text = String(format: "%0.2f %@", vm.amount, vm.symbol)
        self.currencyAmountLabel.text = String(format: "%@%0.2f ", AppSettings.shared.currencyValue == .USD ? "$" : "HK$", vm.currencyAmount)
    }
}
